
#include "ipfe_for_ImageParse.h"

// [*] CFeatureFactory_ImageParse

CFeatureFactory_ImageParse::CParameters CFeatureFactory_ImageParse::Parameters;

CImageFilterBank* CFeatureFactory_ImageParse::GenerateFilterBank_MultiScale_A()
{
	int i;

	CImageFilterBank* ret = new CImageFilterBank();
	ret->myInit();

	CImageFilter_RGB* pFilter_RGB = ret->pBasicFilter_RGB;

	CImageFilter_Lab* pFilter_Lab = new CImageFilter_Lab();
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Lab);

	CImageFilter_Gaussian* pFilter_Gaussian_1 = new CImageFilter_Gaussian(Parameters.TextonSigma * 1.0);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_1);

	CImageFilter_Gaussian* pFilter_Gaussian_2 = new CImageFilter_Gaussian(Parameters.TextonSigma * 2.0);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_2);

	CImageFilter_Gaussian* pFilter_Gaussian_4 = new CImageFilter_Gaussian(Parameters.TextonSigma * 4.0);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_4);

	CImageFilter_LoG* pFilter_LoG_1 = new CImageFilter_LoG(Parameters.TextonSigma * 1.0);
	pFilter_LoG_1->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_1);

	CImageFilter_LoG* pFilter_LoG_2 = new CImageFilter_LoG(Parameters.TextonSigma * 2.0);
	pFilter_LoG_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_2);

	CImageFilter_LoG* pFilter_LoG_4 = new CImageFilter_LoG(Parameters.TextonSigma * 4.0);
	pFilter_LoG_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_4);

	CImageFilter_LoG* pFilter_LoG_8 = new CImageFilter_LoG(Parameters.TextonSigma * 8.0);
	pFilter_LoG_8->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_8);

	CImageFilter_1DoG* pFilter_1DoG_X_2 = new CImageFilter_1DoG(true, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_X_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_X_2);

	CImageFilter_1DoG* pFilter_1DoG_Y_2 = new CImageFilter_1DoG(false, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_Y_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_Y_2);

	CImageFilter_1DoG* pFilter_1DoG_X_4 = new CImageFilter_1DoG(true, Parameters.TextonSigma * 4.0);
	pFilter_1DoG_X_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_X_4);

	CImageFilter_1DoG* pFilter_1DoG_Y_4 = new CImageFilter_1DoG(false, Parameters.TextonSigma * 4.0);
	pFilter_1DoG_Y_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_Y_4);

	CImageFilter_DooG* pFilter_DooG_a[6];
	for ( i = 0; i < 6; ++i )
	{
		pFilter_DooG_a[i] = new CImageFilter_DooG(1.5, i*PI/6, 3.0);
		pFilter_DooG_a[i]->PushBackInputResponse(pFilter_Lab, 0);
		ret->PushBackFilter(pFilter_DooG_a[i]);
	}

	CImageFilter_DooG* pFilter_DooG_b[6];
	for ( i = 0; i < 6; ++i )
	{
		pFilter_DooG_b[i] = new CImageFilter_DooG(1.8, i*PI/6, 3.0);
		pFilter_DooG_b[i]->PushBackInputResponse(pFilter_Lab, 0);
		ret->PushBackFilter(pFilter_DooG_b[i]);
	}

	CImageFilter_DoG* pFilter_DoG_1 = new CImageFilter_DoG(1.0);
	pFilter_DoG_1->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_DoG_1);

	CImageFilter_DoG* pFilter_DoG_2 = new CImageFilter_DoG(1.5);
	pFilter_DoG_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_DoG_2);

	CImageFilter_DoG* pFilter_DoG_3 = new CImageFilter_DoG(3.0);
	pFilter_DoG_3->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_DoG_3);

	CImageFilter_DoG* pFilter_DoG_4 = new CImageFilter_DoG(4.0);
	pFilter_DoG_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_DoG_4);

	// Setting Response Output

	pFilter_RGB->PushBackOutput(0);			// R
	pFilter_RGB->PushBackOutput(1);			// G
	pFilter_RGB->PushBackOutput(2);			// B

	pFilter_Lab->PushBackOutput(0);			// L
	
	pFilter_Gaussian_1->PushBackOutput(0);
	pFilter_Gaussian_1->PushBackOutput(1);
	pFilter_Gaussian_1->PushBackOutput(2);
	pFilter_Gaussian_2->PushBackOutput(0);
	pFilter_Gaussian_2->PushBackOutput(1);
	pFilter_Gaussian_2->PushBackOutput(2);
	pFilter_Gaussian_4->PushBackOutput(0);
	pFilter_Gaussian_4->PushBackOutput(1);
	pFilter_Gaussian_4->PushBackOutput(2);

	pFilter_LoG_1->PushBackOutput(0);
	pFilter_LoG_2->PushBackOutput(0);
	pFilter_LoG_4->PushBackOutput(0);
	pFilter_LoG_8->PushBackOutput(0);

	pFilter_1DoG_X_2->PushBackOutput(0);
	pFilter_1DoG_Y_2->PushBackOutput(0);
	pFilter_1DoG_X_4->PushBackOutput(0);
	pFilter_1DoG_Y_4->PushBackOutput(0);

	for ( i = 0; i < 6; ++i )
		pFilter_DooG_a[i]->PushBackOutput(0);
	for ( i = 0; i < 6; ++i )
		pFilter_DooG_b[i]->PushBackOutput(0);

	pFilter_DoG_1->PushBackOutput(0);
	pFilter_DoG_2->PushBackOutput(0);
	pFilter_DoG_3->PushBackOutput(0);
	pFilter_DoG_4->PushBackOutput(0);

	// Finish Filter Bank Initialization

	ret->GetOutputDimension(true);

	ret->SetCachePath(Parameters.strPN_IFB_Cache);

	int AreaThreshold = (400+32) * (300+32);

	// From Slowest

	//pFilter_DoG_4->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DoG_3->AreaThresholdForResponseCacheUsage = AreaThreshold;

	//pFilter_DooG_a[2]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_a[5]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_b[2]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_b[5]->AreaThresholdForResponseCacheUsage = AreaThreshold;

	//pFilter_DooG_a[1]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_a[4]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_b[1]->AreaThresholdForResponseCacheUsage = AreaThreshold;
	//pFilter_DooG_b[4]->AreaThresholdForResponseCacheUsage = AreaThreshold;

	return ret;
}

CImageFilterBank* CFeatureFactory_ImageParse::GenerateFilterBank_MultiScale_B()
{
	//int i;

	CImageFilterBank* ret = new CImageFilterBank();
	ret->myInit();

	CImageFilter_RGB* pFilter_RGB = ret->pBasicFilter_RGB;

	CImageFilter_Lab* pFilter_Lab = new CImageFilter_Lab();
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Lab);

	CImageFilter_Gaussian* pFilter_Gaussian_1 = new CImageFilter_Gaussian(Parameters.TextonSigma * 1.0);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_1->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_1);

	CImageFilter_Gaussian* pFilter_Gaussian_2 = new CImageFilter_Gaussian(Parameters.TextonSigma * 2.0);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_2->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_2);

	CImageFilter_Gaussian* pFilter_Gaussian_4 = new CImageFilter_Gaussian(Parameters.TextonSigma * 4.0);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian_4->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian_4);

	CImageFilter_LoG* pFilter_LoG_1 = new CImageFilter_LoG(Parameters.TextonSigma * 1.0);
	pFilter_LoG_1->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_1);

	CImageFilter_LoG* pFilter_LoG_2 = new CImageFilter_LoG(Parameters.TextonSigma * 2.0);
	pFilter_LoG_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_2);

	CImageFilter_LoG* pFilter_LoG_4 = new CImageFilter_LoG(Parameters.TextonSigma * 4.0);
	pFilter_LoG_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_4);

	CImageFilter_LoG* pFilter_LoG_8 = new CImageFilter_LoG(Parameters.TextonSigma * 8.0);
	pFilter_LoG_8->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG_8);

	CImageFilter_1DoG* pFilter_1DoG_X_2 = new CImageFilter_1DoG(true, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_X_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_X_2);

	CImageFilter_1DoG* pFilter_1DoG_Y_2 = new CImageFilter_1DoG(false, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_Y_2->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_Y_2);

	CImageFilter_1DoG* pFilter_1DoG_X_4 = new CImageFilter_1DoG(true, Parameters.TextonSigma * 4.0);
	pFilter_1DoG_X_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_X_4);

	CImageFilter_1DoG* pFilter_1DoG_Y_4 = new CImageFilter_1DoG(false, Parameters.TextonSigma * 4.0);
	pFilter_1DoG_Y_4->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_Y_4);

	CImageFilter_Gradient* pFilter_Gradient_2 = new CImageFilter_Gradient(Parameters.TextonSigma * 2.0, false);
	pFilter_Gradient_2->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Gradient_2->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Gradient_2->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Gradient_2);

	CImageFilter_2D_Histogram* pFilter_2D_Histogram_2 = 
		new CImageFilter_2D_Histogram(0, 1, 9, -PI/2, +PI/2, CImageFilter_2D_Histogram::MODE_BOUNDING, true);
	pFilter_2D_Histogram_2->PushBackInputResponse(pFilter_Gradient_2, 0);
	pFilter_2D_Histogram_2->PushBackInputResponse(pFilter_Gradient_2, 1);
	ret->PushBackFilter(pFilter_2D_Histogram_2);

	CImageFilter_Gradient* pFilter_Gradient_4 = new CImageFilter_Gradient(Parameters.TextonSigma * 4.0, false);
	pFilter_Gradient_4->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Gradient_4->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Gradient_4->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Gradient_4);

	CImageFilter_2D_Histogram* pFilter_2D_Histogram_4 = 
		new CImageFilter_2D_Histogram(0, 1, 9, -PI/2, +PI/2, CImageFilter_2D_Histogram::MODE_BOUNDING, true);
	pFilter_2D_Histogram_4->PushBackInputResponse(pFilter_Gradient_4, 0);
	pFilter_2D_Histogram_4->PushBackInputResponse(pFilter_Gradient_4, 1);
	ret->PushBackFilter(pFilter_2D_Histogram_4);

	// Setting Response Output

	pFilter_RGB->PushBackOutput(0);			// R
	pFilter_RGB->PushBackOutput(1);			// G
	pFilter_RGB->PushBackOutput(2);			// B

	pFilter_Gaussian_1->PushBackOutput(0);
	pFilter_Gaussian_1->PushBackOutput(1);
	pFilter_Gaussian_1->PushBackOutput(2);
	pFilter_Gaussian_2->PushBackOutput(0);
	pFilter_Gaussian_2->PushBackOutput(1);
	pFilter_Gaussian_2->PushBackOutput(2);
	pFilter_Gaussian_4->PushBackOutput(0);
	pFilter_Gaussian_4->PushBackOutput(1);
	pFilter_Gaussian_4->PushBackOutput(2);

	pFilter_LoG_1->PushBackOutput(0);
	pFilter_LoG_2->PushBackOutput(0);
	pFilter_LoG_4->PushBackOutput(0);
	pFilter_LoG_8->PushBackOutput(0);

	pFilter_1DoG_X_2->PushBackOutput(0);
	pFilter_1DoG_Y_2->PushBackOutput(0);
	pFilter_1DoG_X_4->PushBackOutput(0);
	pFilter_1DoG_Y_4->PushBackOutput(0);

	pFilter_2D_Histogram_2->PushBackOutput(0);
	pFilter_2D_Histogram_2->PushBackOutput(1);
	pFilter_2D_Histogram_2->PushBackOutput(2);
	pFilter_2D_Histogram_2->PushBackOutput(3);
	pFilter_2D_Histogram_2->PushBackOutput(4);
	pFilter_2D_Histogram_2->PushBackOutput(5);
	pFilter_2D_Histogram_2->PushBackOutput(6);
	pFilter_2D_Histogram_2->PushBackOutput(7);
	pFilter_2D_Histogram_2->PushBackOutput(8);

	pFilter_2D_Histogram_4->PushBackOutput(0);
	pFilter_2D_Histogram_4->PushBackOutput(1);
	pFilter_2D_Histogram_4->PushBackOutput(2);
	pFilter_2D_Histogram_4->PushBackOutput(3);
	pFilter_2D_Histogram_4->PushBackOutput(4);
	pFilter_2D_Histogram_4->PushBackOutput(5);
	pFilter_2D_Histogram_4->PushBackOutput(6);
	pFilter_2D_Histogram_4->PushBackOutput(7);
	pFilter_2D_Histogram_4->PushBackOutput(8);

	// Finish Filter Bank Initialization

	ret->GetOutputDimension(true);

	ret->SetCachePath(Parameters.strPN_IFB_Cache);

	int AreaThreshold = (400+32) * (300+32);

	// From Slowest

	return ret;
}

CImageFilterBank* CFeatureFactory_ImageParse::GenerateFilterBank_SingleScale()
{
	int i;

	CImageFilterBank* ret = new CImageFilterBank();
	ret->myInit();

	CImageFilter_RGB* pFilter_RGB = ret->pBasicFilter_RGB;

	CImageFilter_Gray* pFilter_Gray = new CImageFilter_Gray();
	pFilter_Gray->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Gray->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Gray->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Gray);

	CImageFilter_Lab* pFilter_Lab = new CImageFilter_Lab();
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Lab->PushBackInputResponse(pFilter_RGB, 2);
	ret->PushBackFilter(pFilter_Lab);

	CImageFilter_Gaussian* pFilter_Gaussian = new CImageFilter_Gaussian(Parameters.TextonSigma * 1.0);
	pFilter_Gaussian->PushBackInputResponse(pFilter_RGB, 0);
	pFilter_Gaussian->PushBackInputResponse(pFilter_RGB, 1);
	pFilter_Gaussian->PushBackInputResponse(pFilter_RGB, 2);
	pFilter_Gaussian->PushBackInputResponse(pFilter_Gray, 0);
	pFilter_Gaussian->PushBackInputResponse(pFilter_Lab, 0);
	pFilter_Gaussian->PushBackInputResponse(pFilter_Lab, 1);
	pFilter_Gaussian->PushBackInputResponse(pFilter_Lab, 2);
	ret->PushBackFilter(pFilter_Gaussian);

	CImageFilter_LoG* pFilter_LoG = new CImageFilter_LoG(Parameters.TextonSigma * 1.0);
	pFilter_LoG->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_LoG);

	CImageFilter_1DoG* pFilter_1DoG_X = new CImageFilter_1DoG(true, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_X->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_X);

	CImageFilter_1DoG* pFilter_1DoG_Y = new CImageFilter_1DoG(false, Parameters.TextonSigma * 2.0);
	pFilter_1DoG_Y->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_1DoG_Y);

	CImageFilter_DooG* pFilter_DooG[6];
	for ( i = 0; i < 6; ++i )
	{
		pFilter_DooG[i] = new CImageFilter_DooG(1.0, i*PI/6, 3.0);
		pFilter_DooG[i]->PushBackInputResponse(pFilter_Lab, 0);
		ret->PushBackFilter(pFilter_DooG[i]);
	}

	CImageFilter_DoG* pFilter_DoG = new CImageFilter_DoG(1.0);
	pFilter_DoG->PushBackInputResponse(pFilter_Lab, 0);
	ret->PushBackFilter(pFilter_DoG);

	// Setting Response Output

	pFilter_RGB->PushBackOutput(0);			// R
	pFilter_RGB->PushBackOutput(1);			// G
	pFilter_RGB->PushBackOutput(2);			// B
	pFilter_Lab->PushBackOutput(0);			// L
	//pFilter_Gaussian->PushBackOutput(0);	// Gaussian(R)
	//pFilter_Gaussian->PushBackOutput(1);	// Gaussian(G)
	//pFilter_Gaussian->PushBackOutput(2);	// Gaussian(B)
	//pFilter_Gaussian->PushBackOutput(3);	// Gaussian(Gray)

	pFilter_Gaussian->PushBackOutput(4);	// Gaussian(L)
	pFilter_Gaussian->PushBackOutput(5);	// Gaussian(a)
	pFilter_Gaussian->PushBackOutput(6);	// Gaussian(b)
	pFilter_LoG->PushBackOutput(0);			// LoG(L)
	pFilter_1DoG_X->PushBackOutput(0);		// 1DoG_X(L)
	pFilter_1DoG_Y->PushBackOutput(0);		// 1DoG_Y(L)
	for ( i = 0; i < 6; ++i )
		pFilter_DooG[i]->PushBackOutput(0);	// DooG(L, i*PI/6)
	pFilter_DoG->PushBackOutput(0);		// DoG(L)

	// Finish Filter Bank Initialization

	ret->GetOutputDimension(true);

	return ret;
}

CImagePositionFeatureExtractor* CFeatureFactory_ImageParse::GenerateIPFE(CImageFilterBank* pFixedImageFilterBank)
{
#if 1
	int i;
	C_IPFC_ImageFilterBankOwner* pIFBO = new C_IPFC_ImageFilterBankOwner(pFixedImageFilterBank->myClone(), Parameters.ImageExtent, false);
	for ( i = 0; i < pFixedImageFilterBank->GetOutputDimension(); ++i )
		pIFBO->PushBackResponseUser(new C_IPFC_ResponseUser_MeanAndVairance(&Parameters.ShapePatternList), &i);

	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();
	pCompositeIPFC->PushBack(pIFBO);
#else
	int i, ii;
	CSimpleTypeArray<int> InputResponseList;
	InputResponseList.Clear();
	ii = pFixedImageFilterBank->GetOutputDimension();
	for ( i = 0; i < ii; ++i )
		InputResponseList.PushBack(i);

	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();

	pCompositeIPFC->PushBack(
		new CResponseMeanAndVarianceIPFC(
			pFixedImageFilterBank, Parameters.ImageExtent, InputResponseList, &Parameters.ShapePatternList
			)
		);
#endif

	CImagePositionFeatureExtractor* ret = new CBasicIPFE(pCompositeIPFC);

	return ret;
}

CImagePyramidPositionFeatureExtractor* CFeatureFactory_ImageParse::GenerateIPPFE(CImageFilterBank* pFixedImageFilterBank, int CacheSize)
{
	CImagePositionFeatureExtractor* pt = GenerateIPFE(pFixedImageFilterBank);
	CImagePyramidPositionFeatureExtractor* ret = new CImagePyramidPositionFeatureExtractor(pt, CacheSize);
	return ret;
}

//// [*] C_IPFE_Factory_ImageParse
//
//C_IPFE_Factory_ImageParse::CParameters C_IPFE_Factory_ImageParse::Parameters;
//
//CImagePositionFeatureExtractor* C_IPFE_Factory_ImageParse::GenerateIPFE()
//{
//	int i;
//	_C_ImageFilter* pImageFilter;
//
//	CSimpleTypeArray<_C_ImageFilter*> ImageFilterPtrList;
//	ImageFilterPtrList.Clear();
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(1));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(2));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(3));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, Parameters.TextonSigma * 1.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, Parameters.TextonSigma * 2.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, Parameters.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, Parameters.TextonSigma * 1.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, Parameters.TextonSigma * 2.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, Parameters.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, Parameters.TextonSigma * 1.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, Parameters.TextonSigma * 2.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, Parameters.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, Parameters.TextonSigma * 1.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, Parameters.TextonSigma * 2.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, Parameters.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, Parameters.TextonSigma * 8.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, Parameters.TextonSigma * 2.0, true));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, Parameters.TextonSigma * 4.0, true));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, Parameters.TextonSigma * 2.0, false));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, Parameters.TextonSigma * 4.0, false));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 0.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 1.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 2.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 3.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 4.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 5.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 0.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 1.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 2.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 3.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 4.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 5.0*PI/6, 3.0));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 1.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 1.5));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 4.0));
//
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.0, 0.334, 0.667, 0.0, (PI+PI)/1));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.0, 0.334, 0.667, 0*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.0, 0.334, 0.667, 1*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.0, 0.334, 0.667, 2*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.0, 0.334, 0.667, 3*PI/4, (PI+PI)/4));
//
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.5, 0.500, 0.833, 0.0, (PI+PI)/1));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.5, 0.500, 0.833, 0*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.5, 0.500, 0.833, 1*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.5, 0.500, 0.833, 2*PI/4, (PI+PI)/4));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_CannyEdge(3, 1.5, 0.500, 0.833, 3*PI/4, (PI+PI)/4));
//
//	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();
//
//	for ( i = 0; i < (int)ImageFilterPtrList.Size; ++i )
//	{
//		pImageFilter = ImageFilterPtrList.pElement[i];
//		ImageFilterPtrList.pElement[i] = NULL;
//
//		//pCompositeIPFC->PushBack(
//		//	new CResponseMeanIPFC(
//		//		pImageFilter->myClone(), &Parameters.ShapePatternList_ForMeanOnly
//		//		)
//		//	);
//		//pCompositeIPFC->PushBack(
//		//	new CResponseMeanAndVarianceIPFC(
//		//		pImageFilter->myClone(), &Parameters.ShapePatternList_ForMeanAndVariance
//		//		)
//		//	);
//
//		delete pImageFilter;
//		pImageFilter = NULL;
//	}
//
//	CImagePositionFeatureExtractor* ret = new CBasicIPFE(pCompositeIPFC, Parameters.ImageExtent);
//
//	return ret;
//}
//
//// [*] C_IPPFE_Factory_ImageParse
//
//C_IPPFE_Factory_ImageParse::CParameters C_IPPFE_Factory_ImageParse::IPFE_Config;
//
//CImagePositionFeatureExtractor* C_IPPFE_Factory_ImageParse::GenerateIPFE()
//{
//	int i;
//	_C_ImageFilter* pImageFilter;
//
//	CSimpleTypeArray<_C_ImageFilter*> ImageFilterPtrList;
//	ImageFilterPtrList.Clear();
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(1));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(2));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_ColorChannel(3));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, IPFE_Config.TextonSigma * 1.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, IPFE_Config.TextonSigma * 2.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(3, IPFE_Config.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, IPFE_Config.TextonSigma * 1.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, IPFE_Config.TextonSigma * 2.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(4, IPFE_Config.TextonSigma * 4.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, IPFE_Config.TextonSigma * 1.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, IPFE_Config.TextonSigma * 2.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_Gaussian(5, IPFE_Config.TextonSigma * 4.0));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, IPFE_Config.TextonSigma * 1.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, IPFE_Config.TextonSigma * 2.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, IPFE_Config.TextonSigma * 4.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_LoG(3, IPFE_Config.TextonSigma * 8.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, IPFE_Config.TextonSigma * 2.0, true));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, IPFE_Config.TextonSigma * 4.0, true));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, IPFE_Config.TextonSigma * 2.0, false));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_1DoG(3, IPFE_Config.TextonSigma * 4.0, false));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 0.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 1.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 2.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 3.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 4.0*PI/6, 3.0));
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.0, 5.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 0.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 1.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 2.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 3.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 4.0*PI/6, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DooG(3, 1.8, 5.0*PI/6, 3.0));
//
//	ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 1.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 1.5));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 3.0));
//	//ImageFilterPtrList.PushBack(new _C_ImageFilter_DoG(3, 4.0));
//
//	CCompositeIPFC* pCompositeIPFC = new CCompositeIPFC();
//
//	for ( i = 0; i < (int)ImageFilterPtrList.Size; ++i )
//	{
//		pImageFilter = ImageFilterPtrList.pElement[i];
//		ImageFilterPtrList.pElement[i] = NULL;
//
//		//pCompositeIPFC->PushBack(
//		//	new CResponseMeanAndVarianceIPFC(
//		//	pImageFilter->myClone(), &IPFE_Config.ShapePatternList_ForMeanAndVariance
//		//	)
//		//	);
//
//		delete pImageFilter;
//		pImageFilter = NULL;
//	}
//
//	CImagePositionFeatureExtractor* ret = new CBasicIPFE(pCompositeIPFC, IPFE_Config.ImageExtent);
//
//	return ret;
//}
//
//CImagePyramidPositionFeatureExtractor* C_IPPFE_Factory_ImageParse::GenerateIPPFE(int CacheSize)
//{
//	CImagePositionFeatureExtractor* pIPFE = GenerateIPFE();
//	CImagePyramidPositionFeatureExtractor* ret = new CImagePyramidPositionFeatureExtractor(pIPFE, CacheSize);
//	return ret;
//}

